Logging HOWTO
This package is built with Python's logging module as a reference. If you have never used Python logging before, we recommend that you read the following documentation first.
The code in this page can also be found in Examples in the repository.
Hello world
Logging provides a set of convenience functions for simple logging usage.
The logging functions are named after the level or severity of the events they are used to track. The standard levels and their applicability are described below (in increasing order of severity):
table:loglevel
Level When it's used
Debug Detailed information, typically of interest only when diagnosing problems.
Info Confirmation that things are working as expected.
Warning An indication that something unexpected happened, or indicative of some problem
in the near future (e.g. ‘disk space low’). The software is still working as expected.
Error Due to a more serious problem, the software has not been able to perform some
function.
Critical A serious error, indicating that the program itself may be unable to continue
running.
The Root Logger's default level is LogLevel.Warning, which means that only events of this level and above will be tracked, unless the logging package is configured to do otherwise. For more information on LogLevel, see LogLevel. A simple example
https://gyazo.com/4519ddcb6db915599116a7f2c87688c3
If you are using .asmdef, please add Edanoue.Logging to Assembly Definition References.
A very simple example is:
code:cs
using Edanoue.Logging;
code:cs
public void Awake()
{
Logging.Warning("Watch out!"); // will print a message to the console
Logging.Info("I told you so"); // will not print anything
}
code:UnityConsoleWindow
Set the level of logging output by the root logger
code:cs
public void Awake()
{
// Anything with a severity lower than "Error" is ignored by root logger default.
Logging.Info("Ignored");
// Sets the minimum level at which the route logger outputs.
Logging.SetLevel(LogLevel.Info);
Logging.Info("Info message");
}
code:UnityConsoleWindow